home *** CD-ROM | disk | FTP | other *** search
/ PC User 2002 April / Disc 2 / PCUSER0402D2.iso / software / utils / files / wincron.exe / data1.cab / Sample_Scripts / C / env_test.c next >
Encoding:
C/C++ Source or Header  |  2001-10-20  |  585 b   |  44 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "win32.h"
  5.  
  6. int doit(int ix);
  7.  
  8. int main(int argc, char **argv)
  9. {
  10.     
  11.     int ix;
  12.  
  13.     for (ix=0; ix < 8 * 1024; ix++)
  14.     {
  15.         doit(ix);
  16.     }
  17.  
  18.     fflush(stdout);
  19.     
  20.     return 0;
  21. }
  22.  
  23. int doit(int ix)
  24. {
  25.     char buff[128];
  26.     char* cp;
  27.  
  28.     itoa(ix,buff,10);
  29.     SetEnvironmentVariable("COUNT", buff);
  30.     GetEnvironmentVariable("COUNT", buff, 128);
  31.  
  32.     cp = malloc(strlen(buff)+1);
  33.     if (cp)
  34.     {
  35.         strcpy(cp,buff);
  36.         printf("COUNT=%s\n",cp);
  37.         free(cp);
  38.     }
  39.     else
  40.         printf("MEMORY ERROR\n");
  41.  
  42.     return 0;
  43. }
  44.